import api from "@/request/index";
import * as CONSTANTS from "@constants/index";
import { iGetDataParams } from "../types";
import * as services from "../services";
import * as selectors from "./selectors";
import descriptions from "@/assets/json/description.json"

export const getAlbum = async (p: iGetDataParams): Promise<[]> => {
  let response: any = [];
  response = await services.getAlbum(p);
  response = selectors.getAlbumList(response);
  response = selectors.filterProps(response, ['id', 'name', 'coverImage', 'labels', 'description']);
  response = selectors.addDefaultDescription(response, descriptions['data']);
  response = selectors.addIndex(response);
  response = selectors.addQuality(response);


  return response;
}

export const uploadVisitEvent = async (p: any): Promise<void> => {
  const event = CONSTANTS.EVENT_ACTIVE_HHTERGE_VISIT;
  const url = window.location.href;
  p = { ...p, event, url }
  await services.uploadEvents(p);
}

export const uploadClickEvent = async (p: any): Promise<void> => {
  const event = CONSTANTS.EVENT_ACTIVE_HHTERGE_CLICK;
  p = { ...p, event }
  await services.uploadEvents(p);
}